﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using ThoiTrang.Entities;
using ThoiTrang.Business;
using System.Collections.Generic;

public partial class reportsurvey : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected string GetHtmlCode()
    {
        string res = string.Empty;
        try
        {
            string question = "";
            int qid = 0;
            double totalCount = 0;
            List<a_Surveys_Option> opts = a_Surveys_OptionService.Geta_Surveys_OptionList(out question, out qid);
            res += String.Format("\t\t\t\t\t\t\t<p><strong>{0}</strong></p>\n", question);
            res += "\t\t\t\t\t\t\t<div class=\"copy-content clear\">\n";

            //********************************************************DIV u1*************************************************************
            res += "\t\t\t\t\t\t\t\t<div class=\"u1\">\n";
            res += "\t\t\t\t\t\t\t\t\t<ul>\n";
            foreach(a_Surveys_Option opt in opts)
            {
                res += String.Format("\t\t\t\t\t\t\t\t\t\t<li>{0}</li>", opt.RespOption);
                totalCount += opt.RespCount;
            }
            res += "\t\t\t\t\t\t\t\t\t</ul>\n";
            res += "\t\t\t\t\t\t\t\t</div>\n";
            //********************************************************DIV u1(end)********************************************************

            //********************************************************DIV u2*************************************************************
            res += "\t\t\t\t\t\t\t\t<div class=\"u2\">\n";
            res += "\t\t\t\t\t\t\t\t\t<ul>\n";
            foreach (a_Surveys_Option opt in opts)
            {
                int temp = (int)(opt.RespCount*100 / totalCount);
                res += String.Format("\t\t\t\t\t\t\t\t\t\t<li><div style=\"width:{0}px; height:16px; background-color: #e55a5d;\"></div></li>", temp.ToString());
            }
            res += "\t\t\t\t\t\t\t\t\t</ul>\n";
            res += "\t\t\t\t\t\t\t\t</div>\n";
            //********************************************************DIV u2(end)********************************************************

            //********************************************************DIV u3*************************************************************
            res += "\t\t\t\t\t\t\t\t<div class=\"u3\">\n";
            res += "\t\t\t\t\t\t\t\t\t<ul>\n";
            foreach (a_Surveys_Option opt in opts)
            {
                float temp = (float)Math.Round(opt.RespCount * 10000 / totalCount) / 100;
                res += String.Format("\t\t\t\t\t\t\t\t\t\t<li>{0} %</li>", temp.ToString());
            }
            res += "\t\t\t\t\t\t\t\t\t</ul>\n";
            res += "\t\t\t\t\t\t\t\t</div>\n";
            //********************************************************DIV u3(end)********************************************************

            res += "\t\t\t\t\t\t\t</div>\n";
        }
        catch (Exception ex)
        {
        }
        return res;
    }

    
}

